home *** CD-ROM | disk | FTP | other *** search
- From: bill@amber.ssd.hcsc.com (Bill Leonard)
- Message-ID: <4i9cn4$7cf@ns.hcsc.com>
- X-Original-Date: 14 Mar 1996 15:07:16 GMT
- Path: in2.uu.net!bounce-back
- Date: 14 Mar 96 16:29:27 GMT
- Approved: fjh@cs.mu.oz.au
- Newsgroups: comp.std.c++
- Subject: Re: String value of enum
- Organization: Harris Computer Systems, Ft. Lauderdale FL
- References: <4i5sf3$89c@hermes.is.co.za> <Do81tp.H9u@rsvl.unisys.com> <4i8a38$2qq@engnews1.Eng.Sun.COM>
- Reply-To: Bill.Leonard@mail.hcsc.com
- X-Auth: PGPMoose V1.1 PGP comp.std.c++
- iQBFAgUBMUhJe+EDnX0m9pzZAQHe2AF/YM+v92fxiWmQnaoGOXpdRcIT0mxXHxu4
- CcrblhPc1Ay4d2ykIv2Eh3SsA52SLkx6
- =joSR
-
- In article <4i8a38$2qq@engnews1.Eng.Sun.COM>, clamage@Eng.Sun.COM
- (Steve Clamage) writes:
- > It would not in fact be difficult to do, since only a table of
- > strings per enum type would be needed. The information is normally
- > put into debug info if you compile in debug mode anyway so the
- > debugger can display the labels instead of the values. A language
- > mechanism to make that data always available is probably too
- > expensive a price for every program to pay in order to support
- > this requirement which isn't very common and which can be solved
- > easily in source code.
-
- Well, it is not that hard for the compiler to put out the tables only if
- you use the feature, so there is no need for every program to pay a penalty
- for this feature.
-
- As for "solved easily in source code", it's not nearly as easy as just
- saying something like "enumvar.String()". :-)
-
- > The more general case of non-contiguous enum values could be handled
- > by a table of value/string pairs and a lookup function. The standard
- > "map" class will do it all for you.
-
- But using the map class would require initialization at runtime, wouldn't
- it? That increases the startup cost of the program. Using a sorted array
- of value/string pairs (statically initialized) and a binary search would
- probably be more efficient.
-
- --
- Bill Leonard
- Harris Computer Systems Corporation
- 2101 W. Cypress Creek Road
- Fort Lauderdale, FL 33309
- Bill.Leonard@mail.hcsc.com
-
- These opinions and statements are my own and do not necessarily reflect the
- opinions or positions of Harris Computer Systems Corporation.
-
- ------------------------------------------------------------------------------
- There's something wrong with an industry in which amazement is a common
- reaction to things going right.
-
- "Hard work never scared me. Oh, sure, it has startled me from a distance."
- -- Professor Fishhawk
- ------------------------------------------------------------------------------
- ---
- [ comp.std.c++ is moderated. To submit articles: try just posting with ]
- [ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
- [ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
- [ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
- [ Comments? mailto:std-c++-request@ncar.ucar.edu ]
-